home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Source.bin / AnimatorBeanInfo.java < prev    next >
Text File  |  1998-08-21  |  12KB  |  321 lines

  1. package symantec.itools.multimedia;
  2.  
  3. import java.beans.*;
  4. import symantec.itools.beans.*;
  5. import java.util.ResourceBundle;
  6.  
  7. //  08/30/97    LAB    Removed extraneous semicolon in getImageList interacion (Addresses Mac Bug #7672).
  8. //  08/19/98    LAB    Moved to GroupAWTMultimedia folder.
  9.  
  10. /**
  11.  * BeanInfo for Animator.
  12.  *
  13.  */
  14.  
  15. public class AnimatorBeanInfo extends SimpleBeanInfo {
  16.  
  17.     /**
  18.      * Constructs a AnimatorBeanInfo object.
  19.      */
  20.     public AnimatorBeanInfo() {
  21.     }
  22.  
  23.     /**
  24.      * Gets a BeanInfo for the superclass of this bean.
  25.      * @return BeanInfo[] containing this bean's superclass BeanInfo
  26.      */
  27.     public BeanInfo[] getAdditionalBeanInfo() {
  28.         try {
  29.             BeanInfo[] bi = new BeanInfo[1];
  30.             bi[0] = Introspector.getBeanInfo(beanClass.getSuperclass());
  31.             return bi;
  32.         }
  33.         catch (IntrospectionException e) { throw new Error(e.toString());}
  34.     }
  35.  
  36.     /**
  37.      * Gets the SymantecBeanDescriptor for this bean.
  38.      * @return an object of type SymantecBeanDescriptor
  39.      * @see symantec.itools.beans.SymantecBeanDescriptor
  40.      */
  41.     public BeanDescriptor getBeanDescriptor() {
  42.         ResourceBundle group = ResourceBundle.getBundle("symantec.itools.resources.GroupBundle");
  43.         String s=group.getString("GroupAWTMultimedia"); 
  44.  
  45.         SymantecBeanDescriptor bd = new SymantecBeanDescriptor(beanClass);
  46.         bd.setFolder(s);
  47.         bd.setToolbar(s);
  48.         bd.setWinHelp("0x1239D");
  49.  
  50.         return (BeanDescriptor) bd;
  51.     }
  52.  
  53.     /**
  54.      * Gets an image that may be used to visually represent this bean
  55.      * (in the toolbar, on a form, etc).
  56.      * @param iconKind the type of icon desired, one of: BeanInfo.ICON_MONO_16x16,
  57.      * BeanInfo.ICON_COLOR_16x16, BeanInfo.ICON_MONO_32x32, or BeanInfo.ICON_COLOR_32x32.
  58.      * @return an image for this bean, always color even if requested monochrome
  59.      * @see BeanInfo#ICON_MONO_16x16
  60.      * @see BeanInfo#ICON_COLOR_16x16
  61.      * @see BeanInfo#ICON_MONO_32x32
  62.      * @see BeanInfo#ICON_COLOR_32x32
  63.      */
  64.     public java.awt.Image getIcon(int iconKind) {
  65.         if (iconKind == BeanInfo.ICON_MONO_16x16 ||
  66.             iconKind == BeanInfo.ICON_COLOR_16x16) {
  67.             java.awt.Image img = loadImage("AnimatorC16.gif");
  68.             return img;
  69.         }
  70.  
  71.         if (iconKind == BeanInfo.ICON_MONO_32x32 ||
  72.             iconKind == BeanInfo.ICON_COLOR_32x32) {
  73.             java.awt.Image img = loadImage("AnimatorC32.gif");
  74.             return img;
  75.         }
  76.  
  77.         return null;
  78.     }
  79.  
  80.     /**
  81.      * Gets an array of descriptions of the methods used for "connections" by
  82.      * Visual CafΘ's Interaction Wizard.
  83.      * Included in each method description is a CONNECTIONS ConnectionDescriptor.
  84.      * @return method descriptions for this bean
  85.      * @see symantec.itools.beans.ConnectionDescriptor#CONNECTIONS
  86.      */
  87.     public MethodDescriptor[] getMethodDescriptors() {
  88.         Class[] args;
  89.         ConnectionDescriptor connection;
  90.         java.util.Vector connections;
  91.         java.util.Vector md = new java.util.Vector();
  92.         ResourceBundle conn = ResourceBundle.getBundle("symantec.itools.resources.ConnBundle");
  93.  
  94.         try{
  95.             args = new Class[1];
  96.             args[0] = java.net.URL.class ;
  97.             MethodDescriptor addImage = new MethodDescriptor(beanClass.getMethod("addImage", args));
  98.  
  99.             connections = new java.util.Vector();
  100.             connection = new ConnectionDescriptor("input", "URL", "",
  101.                                     "%name%.addImage(%arg%);",
  102.                                     conn.getString("addImageURL"));
  103.             connections.addElement(connection);
  104.  
  105.             connection = new ConnectionDescriptor("input", "RelativeURL", "",
  106.                                     "%name%.addImage(symantec.itools.net.RelativeURL.getURL(%arg%));",
  107.                                     conn.getString("addImageName"));
  108.             connections.addElement(connection);
  109.  
  110.             addImage.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  111.             md.addElement(addImage);
  112.         } catch (Exception e) { throw new Error("addImage:: " + e.toString()); }
  113.  
  114.         try{
  115.             args = new Class[1];
  116.             args[0] = java.lang.Boolean.TYPE ;
  117.             MethodDescriptor setClearFrame = new MethodDescriptor(beanClass.getMethod("setClearFrame", args));
  118.  
  119.             connections = new java.util.Vector();
  120.             connection = new ConnectionDescriptor("input", "void", "",
  121.                                     "%name%.setClearFrame(true);",
  122.                                     conn.getString("setClearFrameTrue"));
  123.             connections.addElement(connection);
  124.  
  125.             connection = new ConnectionDescriptor("input", "void", "",
  126.                                     "%name%.setClearFrame(false);",
  127.                                     conn.getString("setClearFrameFalse"));
  128.             connections.addElement(connection);
  129.  
  130.             setClearFrame.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  131.             md.addElement(setClearFrame);
  132.         } catch (Exception e) { throw new Error("setClearFrame:: " + e.toString()); }
  133.  
  134.         try{
  135.             args = null;
  136.             MethodDescriptor getNumLoops = new MethodDescriptor(beanClass.getMethod("getNumLoops", args));
  137.  
  138.             connections = new java.util.Vector();
  139.             connection = new ConnectionDescriptor("output", "int", "",
  140.                                     "%name%.getNumLoops()",
  141.                                     conn.getString("getNumLoops"));
  142.             connections.addElement(connection);
  143.  
  144.             getNumLoops.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  145.             md.addElement(getNumLoops);
  146.         } catch (Exception e) { throw new Error("getNumLoops:: " + e.toString()); }
  147.  
  148.         try{
  149.             args = null;
  150.             MethodDescriptor startAnimation = new MethodDescriptor(beanClass.getMethod("startAnimation", args));
  151.  
  152.             connections = new java.util.Vector();
  153.             connection = new ConnectionDescriptor("input", "void", "",
  154.                                     "%name%.startAnimation();",
  155.                                     conn.getString("startAnimation"));
  156.             connections.addElement(connection);
  157.  
  158.             startAnimation.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  159.             md.addElement(startAnimation);
  160.         } catch (Exception e) { throw new Error("startAnimation:: " + e.toString()); }
  161.  
  162.         try{
  163.             args = null;
  164.             MethodDescriptor stopAnimation = new MethodDescriptor(beanClass.getMethod("stopAnimation", args));
  165.  
  166.             connections = new java.util.Vector();
  167.             connection = new ConnectionDescriptor("input", "void", "",
  168.                                     "%name%.stopAnimation();",
  169.                                     conn.getString("stopAnimation"));
  170.             connections.addElement(connection);
  171.  
  172.             stopAnimation.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  173.             md.addElement(stopAnimation);
  174.         } catch (Exception e) { throw new Error("stopAnimation:: " + e.toString()); }
  175.  
  176.         try{
  177.             args = new Class[1];
  178.             args[0] = java.lang.Integer.TYPE ;
  179.             MethodDescriptor setDelay = new MethodDescriptor(beanClass.getMethod("setDelay", args));
  180.  
  181.             connections = new java.util.Vector();
  182.             connection = new ConnectionDescriptor("input", "int", "",
  183.                                     "%name%.setDelay(%arg%);",
  184.                                     conn.getString("setDelay"));
  185.             connections.addElement(connection);
  186.  
  187.             setDelay.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  188.             md.addElement(setDelay);
  189.         } catch (Exception e) { throw new Error("setDelay:: " + e.toString()); }
  190.  
  191.         try{
  192.             args = new Class[1];
  193.             args[0] = java.net.URL[].class ;
  194.             MethodDescriptor setImageList = new MethodDescriptor(beanClass.getMethod("setImageList", args));
  195.  
  196.             connections = new java.util.Vector();
  197.             connection = new ConnectionDescriptor("input", "URL[]", "",
  198.                                     "%name%.setImageList(%arg%);",
  199.                                     conn.getString("setImageList"));
  200.             connections.addElement(connection);
  201.  
  202.             setImageList.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  203.             md.addElement(setImageList);
  204.         } catch (Exception e) { throw new Error("setImageList:: " + e.toString()); }
  205.  
  206.         try{
  207.             args = new Class[1];
  208.             args[0] = java.lang.Integer.TYPE ;
  209.             MethodDescriptor setNumLoops = new MethodDescriptor(beanClass.getMethod("setNumLoops", args));
  210.  
  211.             connections = new java.util.Vector();
  212.             connection = new ConnectionDescriptor("input", "int", "",
  213.                                     "%name%.setNumLoops(%arg%);",
  214.                                     conn.getString("setNumLoops"));
  215.             connections.addElement(connection);
  216.  
  217.             setNumLoops.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  218.             md.addElement(setNumLoops);
  219.         } catch (Exception e) { throw new Error("setNumLoops:: " + e.toString()); }
  220.  
  221.         try{
  222.             args = new Class[1];
  223.             args[0] = java.lang.Boolean.TYPE ;
  224.             MethodDescriptor setRepeatMode = new MethodDescriptor(beanClass.getMethod("setRepeatMode", args));
  225.  
  226.             connections = new java.util.Vector();
  227.             connection = new ConnectionDescriptor("input", "boolean", "",
  228.                                     "%name%.setRepeatMode(%arg%);",
  229.                                     conn.getString("setRepeatMode"));
  230.             connections.addElement(connection);
  231.  
  232.             setRepeatMode.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  233.             md.addElement(setRepeatMode);
  234.         } catch (Exception e) { throw new Error("setRepeatMode:: " + e.toString()); }
  235.  
  236.         try{
  237.             args = null;
  238.             MethodDescriptor getDelay = new MethodDescriptor(beanClass.getMethod("getDelay", args));
  239.  
  240.             connections = new java.util.Vector();
  241.             connection = new ConnectionDescriptor("output", "int", "",
  242.                                     "%name%.getDelay()",
  243.                                     conn.getString("getDelay"));
  244.             connections.addElement(connection);
  245.  
  246.             getDelay.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  247.             md.addElement(getDelay);
  248.         } catch (Exception e) { throw new Error("getDelay:: " + e.toString()); }
  249.  
  250.         try{
  251.             args = null;
  252.             MethodDescriptor getImageList = new MethodDescriptor(beanClass.getMethod("getImageList", args));
  253.  
  254.             connections = new java.util.Vector();
  255.             connection = new ConnectionDescriptor("output", "URL[]", "",
  256.                                     "%name%.getImageList()",
  257.                                     conn.getString("getImageList"));
  258.             connections.addElement(connection);
  259.  
  260.             getImageList.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  261.             md.addElement(getImageList);
  262.         } catch (Exception e) { throw new Error("getImageList:: " + e.toString()); }
  263.  
  264.         MethodDescriptor[] rv = new MethodDescriptor[md.size()];
  265.         md.copyInto(rv);
  266.  
  267.         return rv;
  268.     }
  269.  
  270.     /**
  271.      * Returns descriptions of this bean's properties.
  272.      */
  273.     public PropertyDescriptor[] getPropertyDescriptors() {
  274.         ResourceBundle prop = ResourceBundle.getBundle("symantec.itools.resources.PropBundle");
  275.  
  276.         try{
  277.         PropertyDescriptor delay = new PropertyDescriptor("delay", beanClass);
  278.         delay.setBound(true);
  279.         delay.setConstrained(true);
  280.         delay.setDisplayName(prop.getString("delay"));
  281.  
  282.         PropertyDescriptor numLoops = new PropertyDescriptor("numLoops", beanClass);
  283.         numLoops.setBound(true);
  284.         numLoops.setConstrained(true);
  285.         numLoops.setDisplayName(prop.getString("numLoops"));
  286.  
  287.         PropertyDescriptor repeatMode = new PropertyDescriptor("repeatMode", beanClass);
  288.         repeatMode.setBound(true);
  289.         repeatMode.setConstrained(true);
  290.         repeatMode.setDisplayName(prop.getString("repeatMode"));
  291.  
  292.         PropertyDescriptor imageList = new PropertyDescriptor("imageList", beanClass);
  293.         imageList.setBound(true);
  294.         imageList.setConstrained(true);
  295.         imageList.setDisplayName(prop.getString("imageList"));
  296.         imageList.setValue("URLFILTER", prop.getString("imageURLFILTER"));
  297.  
  298.         PropertyDescriptor clearFrame = new PropertyDescriptor("clearFrame", beanClass);
  299.         clearFrame.setBound(true);
  300.         clearFrame.setConstrained(true);
  301.         clearFrame.setDisplayName(prop.getString("clearFrame"));
  302.  
  303.         PropertyDescriptor previewMode = new PropertyDescriptor("previewMode", beanClass);
  304.         previewMode.setBound(true);
  305.         previewMode.setConstrained(false);
  306.         previewMode.setDisplayName(prop.getString("previewMode"));
  307.  
  308.         PropertyDescriptor[] rv = {
  309.             delay,
  310.             numLoops,
  311.             repeatMode,
  312.             imageList,
  313.             clearFrame,
  314.             previewMode};
  315.         return rv;
  316.         } catch (IntrospectionException e) { throw new Error(e.toString()); }
  317.     }
  318.  
  319.     private final static Class beanClass = Animator.class;
  320.  
  321.     }    //  end of class AnimatorBeanInfo